package com.tmt.im.jpa.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.tmt.data.jpa.entity.TmtBaseEntityId;
import com.tmt.im.common.annotation._AllowUpdate;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.SuperBuilder;
import org.apache.ignite.cache.query.annotations.QuerySqlField;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serial;
import java.sql.Timestamp;

/**
 * 聊天会话成员
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/6 20:28
 * @Version 1.0
 **/
@Getter
@Setter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@EntityListeners({AuditingEntityListener.class})
@Entity
@Table(name = "chat_session_member")
@Tag(name = "chat_session_member", description = "聊天会话成员表")
public class ChatSessionMember extends TmtBaseEntityId {

    @Serial
    private static final long serialVersionUID = -7422518147818190390L;

    @Column(nullable = false)
    private String inviteMsg;

    /**
     * 是否禁止成员在该群中抢手气红包。
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean forbidRedPackage = false;

    /**
     * 是否禁止成员在该群中发言。
     */
    @Column(nullable = false, columnDefinition = "TINYINT(1)")
    private boolean chatBanned = false;

    /**
     * 是否被用户设置为了免打扰
     */
    @Column(name = "do_not_disturb", nullable = false, columnDefinition = "TINYINT(1)")
    private boolean doNotDisturb = false;

    /**
     * 是否被用户设置为了"置顶"。
     */
    @Column(name = "hold_in_top", nullable = false, columnDefinition = "TINYINT(1)")
    private boolean holdInTop = false;

    /**
     * 在群中的角色： 1——群主，2——管理员，3——普通成员。
     */
    @Column(nullable = false)
    private int roleInSession = 3;

    /**
     * 最后发送个member的数据ID
     */
    @Column(name = "last_data_id")
    private Long lastDataId = null;

    /**
     * 群主或管理员对邀请入群或申请入群的审核结果。
     * 0: 群主或管理员尚未审核
     * 1: 群主或管理员审核通过
     * 2: 群主或管理员审核不通过
     */
    @Column(name = "check_status")
    private int checkStatus = 0;

    /**
     * 审核的群主或管理员ID
     */
    @Column(name = "checker_id")
    private Long checkerId;

    /**
     * 群主或管理员对邀请入群或申请入群的审核时间。
     */
    @Column(name = "check_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Timestamp checkTime;

    /**
     * 被邀请人同意或拒绝入群。
     * 0:被邀请人尚未回复
     * 1: 邀请人同意入群
     * 2: 邀请人拒绝入群
     */
    @Column(name = "agree_status", columnDefinition = "TINYINT(1)")
    private int agreeStatus = 0;

    /**
     * 同意或拒绝入群的时间。
     */
    @Column(name = "agree_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Timestamp agreeTime;

    @Column(name = "deleted")
    private boolean deleted = false;

    @Column(name = "delete_time")
    @Temporal(TemporalType.TIMESTAMP)
    private Timestamp deleteTime;

    /**
     * 成员ID
     */
    @Column(name = "member_id")
    private Long memberId;

    /**
     * 成员群昵称
     */
    @Column(name = "member_nick")
    private String memberNick;


    @Column(name = "session_id")
    private Long sessionId;

    @Column(name = "creator_id")
    private Long creatorId;

}
